<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="userAuthorization" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{userAuthorizationHome.managed ? 'Edit' : 'Add'} User authorization</f:facet>



            <s:decorate id="amountField" template="layout/edit.xhtml">
                <ui:define name="label">Amount</ui:define>
                <h:inputText id="amount"
                       required="true"
                          value="#{userAuthorizationHome.instance.amount}"
                           size="26">
                    <a:support event="onblur" reRender="amountField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{userAuthorizationHome.persist}"
                       disabled="#{!userAuthorizationHome.wired}"
                       rendered="#{!userAuthorizationHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{userAuthorizationHome.update}"
                       rendered="#{userAuthorizationHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{userAuthorizationHome.remove}"
                      immediate="true"
                       rendered="#{userAuthorizationHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/UserAuthorization.xhtml"
                rendered="#{userAuthorizationHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty userAuthorizationFrom ? 'UserAuthorizationList' : userAuthorizationFrom}.xhtml"
                rendered="#{!userAuthorizationHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="User">
    <div class="association" id="userParent">

        <h:outputText value="There is no user associated with this userAuthorization."
                   rendered="#{userAuthorizationHome.instance.user == null}"/>

        <rich:dataTable var="_user"
                   value="#{userAuthorizationHome.instance.user}"
                rendered="#{userAuthorizationHome.instance.user != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_user.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Enabled</f:facet>
                <h:outputText value="#{_user.enabled}"/>
            </h:column>
            <h:column>
                <f:facet name="header">First name</f:facet>
                <h:outputText value="#{_user.firstName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Last name</f:facet>
                <h:outputText value="#{_user.lastName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Password</f:facet>
                <h:outputText value="#{_user.password}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Salt</f:facet>
                <h:outputText value="#{_user.salt}"/>
            </h:column>
            <h:column>
                <f:facet name="header">User name</f:facet>
                <h:outputText value="#{_user.userName}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{userAuthorizationHome.instance.user != null ? 'changeParent' : 'selectParent'}" value="#{userAuthorizationHome.instance.user != null ? 'Change' : 'Select'} user"
                       view="/UserList.xhtml">
                <f:param name="from" value="UserAuthorizationEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
